<template>
  <div class="bigBox">
    <div>管理员信息</div>
    <div>
      <span>管理员ID：</span><span>{{ id }}</span>
    </div>
    <div>
      <span>账号：</span><span>{{ account }}</span>
    </div>
    <div>
      <span>用户组：</span><span>{{ userGroup }}</span>
    </div>
    <div>
      <span>创建时间：</span><span>{{ ctime }}</span>
    </div>
    <div>
      <span>管理头像</span>
      <el-upload
        class="avatar-uploader"
        action="http://127.0.0.1:5000/goods/goods_img_upload"
        :show-file-list="false"
        :on-success="headersuccess"
        :data="{ id: myid }"
      >
        <img v-if="imageUrl" :src="imageUrl" class="avatar" />
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
      </el-upload>
    </div>
  </div>
</template>

<script>
import { Perinmation } from "@/apis/user";
import { getYYYYMMDDHHMMSS } from "@/utils/utils";
export default {
  data() {
    return {
      id: "",
      ctime: "",
      account: "",
      userGroup: "",
      imageUrl: "",
    };
  },
  methods: {
    headersuccess(res,file) {
      if(res.code==0){
          this.imageUrl = URL.createObjectURL(file.raw);
        this.$bus.emit('headersuccess',res)
      }
    },
  },
     computed: {
     myid(){
         return localStorage.id
     }
    },
  created() {
    // let id = localStorage.getItem("id");
    Perinmation({ id: localStorage.id }).then((res) => {
      this.ctime = getYYYYMMDDHHMMSS(res.data.accountInfo.ctime);
      this.id = res.data.accountInfo.id;
      this.account = res.data.accountInfo.account;
      this.userGroup = res.data.accountInfo.userGroup;
      this.imageUrl = res.data.accountInfo.imgUrl;
    });
  },
 
};
</script>

<style lang="less">
.el-main[data-v-fae5bece] {
  line-height: 30px;
  text-align: left;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
.bigBox div {
  // height: 40px;
  border-bottom: 1px solid #eceef4;
  line-height: 60px;
  display: flex;
  align-items: center;

  .img {
    width: 50px;
    height: 50px;
    background-color: #ccc;
    margin-left: 10px;
  }
}
</style>